<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Log;
use AlibabaCloud\SDK\Iot\V20180120\Sample;

class ZnyjgController extends Controller{
    public function iottest(){

        $str = '{"reqId":"'.$cid.'","command":"open","sendTime":'.time().',"ttl":10,"body":{"cmd":"cabinets","box":"'.$lid.'"}}';
        $strbase = base64_encode($str);
        $argv['productKey'] = 'a1fwasvRTlW';
        $argv['topicFullName'] = "/". $productKey ."/" . $cid ."/user/get";;
        $argv['messageContent'] = $strbase;
        // $argv['productKey'] = "a1fwasvRTlW";
        // $argv['topicFullName'] = "/a1fwasvRTlW/YJ21040001/user/get";
        // $argv['messageContent'] = "eyJyZXFJZCI6IllKMjEwNDAwMDEiLCJjb21tYW5kIjoib3BlbiIsInNlbmRUaW1lIjoxNjIxNDk2NjgxLCJ0dGwiOjEwLCJib2R5Ijp7ImNtZCI6ImNhYmluZXRzIiwiYm94IjoxfX0=";


        $res = Sample::main($argv);
        // $arr = ['success'=>2];
        // $obj = (Object)($arr);
        if($obj->success==1){ //success
                print_r('success');
        };

    }
}